import {
  MailOutlined,
  PhoneOutlined,
} from '@ant-design/icons';
import React, { useState, useEffect } from 'react';
import ProForm, { ProFormCaptcha, ProFormCheckbox, ProFormText } from '@ant-design/pro-form';
import { connect, useIntl, FormattedMessage, Link } from 'umi';
import FogotCom from '@/components/Fogot';
import styles from './index.less';



const Login = (props) => {
  const { userLogin, submitting } = props;
  const { lastlogininfo } = userLogin;
  const intl = useIntl();


  //提交
  const handleSubmit = (values) => {
    const { dispatch } = props;
    const postdata = {
      phone: values.userName,
      password: values.password
    }

    dispatch({
      type: 'login/login',
      payload: { ...postdata },
    });
  };

  //自动登录
  useEffect(() => {
    if (lastlogininfo.autoLogin && lastlogininfo.userName && lastlogininfo.password) {
      handleSubmit(lastlogininfo);
    }
  }, []);



  return (
    <div className={styles.main}>
      <div className={`${styles.head} spacebt`}>
        <span>忘记密码</span>
        <Link to="/user/login" style={{ fontSize: 14, color: "#fff" }}
        >立即登录</Link>
      </div>
      <div className={`${styles.body} whiteline`}>
        <FogotCom />
      </div>


    </div >
  );
};

export default connect(({ login, global, loading }) => ({
  global,
  userLogin: login,
  submitting: loading.effects['login/login'],
}))(Login);
